package indi.zjh.dp.util;

import org.apache.log4j.Logger;

import net.sf.json.JSONObject;

public class JSONUtil {
	private static Logger logger = Logger.getLogger(JSONUtil.class);
	
	public static String toString(Object obj)
	{
		JSONObject jobj = JSONObject.fromObject(obj);
		return jobj.toString();
	}
	
	public static Object toObject(String jsonstr, Class<?> cls)
	{
		logger.info("转化json字符串为对象:"+jsonstr+", class="+cls.getName());
		JSONObject jobj = JSONObject.fromObject(jsonstr);
		return JSONObject.toBean(jobj, cls);
	}
}
